package entities;

import java.io.Serializable;
import java.util.Date;

import javax.persistence.*;


/**
 * The persistent class for the friends database table.
 * 
 */
@Entity
@Table(name="usermessages")

@NamedQueries({

@NamedQuery(name="getUserBoardMessages", 
		query="SELECT x FROM Usermessage x WHERE x.userboardId.userprofile.userId=:userId AND x.userboardId.type=?1"),

		@NamedQuery(name="getDailyMessages", 
		query="SELECT x FROM Usermessage x WHERE x.postedOn >:yesterday")

})

public class Usermessage implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@GeneratedValue(strategy=GenerationType.AUTO)
	@Column(name="Id", unique=true, nullable=false)
	private int id;

	//bi-directional many-to-one association to Messageboard
    @ManyToOne
	@JoinColumn(name="MessageBoardId", nullable=false)
	private Messageboard userboardId;
    
	//bi-directional many-to-one association to Userprofile
    @ManyToOne
	@JoinColumn(name="FromUserId", nullable=false)
	private Userprofile userprofile;
    
    @Column(name="Text")
	private String textMessage;
    
    //bi-directional many-to-one association to Userphoto
    @ManyToOne
	@JoinColumn(name="PhotoId")
	private Userphoto photoid;

    @Temporal( TemporalType.TIMESTAMP)
	@Column(name="PostedOn", nullable=false)
	private Date postedOn;

    public Usermessage() {
    }

	public int getId() {
		return this.id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public Userprofile getUserprofile1() {
		return this.userprofile;
	}

	public void setUserprofile1(Userprofile userprofile1) {
		this.userprofile = userprofile1;
	}
	
	public Messageboard getUserboard() {
		return this.userboardId;
	}

	public void setUserboard(Messageboard userboard) {
		this.userboardId = userboard;
	}

	public void setTextMessage(String textMessage) {
		this.textMessage = textMessage;
	}

	public String getTextMessage() {
		return textMessage;
	}

	public void setPhotoId(Userphoto photoId) {
		this.photoid = photoId;
	}

	public Userphoto getPhotoId() {
		return photoid;
	}

	public void setPostedOn(Date postedOn) {
		this.postedOn = postedOn;
	}

	public Date getPostedOn() {
		return postedOn;
	}
	
}